/**
 * 判断数据类型的几种方式
 * typeof  基本类型能识别(除了null)，引用对象的判断结果为object
 * instanceof 用来判断引用类型，包装类型 扩展点原型链
 * constructor  返回对象的构造函数  数组有Array.isArray
 * Object.prototype.toString.call(obj)
 * 让我们用Object原型上的toString方法作用在传入的obj的上下文中（通过call将this指向obj
 */
//typeof
//基本类型 5种 +1 Symbol
console.log(typeof 1);//number
console.log(typeof '1');//string
console.log(typeof true);//boolean
console.log(typeof false);//boolean
console.log(typeof null);//object
console.log(typeof undefined);//undefined
// Symbol
console.log(typeof Symbol(1));//symbol
//引用类型 大体上有Object 和Function
console.log(typeof new Object());//object
console.log(typeof new Function());//function

//数组，Date,RegExp
console.log(typeof [1,,3,4]);//object
console.log(typeof new Date());//object
console.log(typeof /^d+/g);//object
//包装类 Number Boolean String
console.log(typeof new Number('1'));//Object
console.log(typeof new Boolean(1));//Object
console.log(typeof new String(1));//Object

//instanceof
//a instanceof b  判断b的prototype是否在a的原型链上,a是否是b的实例
//引用对象
console.log( {} instanceof Object);
console.log( function(){} instanceof Function);
console.log( [] instanceof Array);
console.log( new Date() instanceof Date);
console.log( /^d+/ instanceof RegExp);
//包装类 Number Boolean String
console.log(new Number('1') instanceof Number);//true
console.log(new Boolean(false) instanceof Boolean);//true
console.log(new String('1') instanceof String);//true

console.log(new Number('1') instanceof Object);//true
console.log(new Boolean(false) instanceof Object);//true
console.log(new String('1') instanceof Object);//true
//引申 原型链
console.log( {} instanceof Object);//true
console.log( function(){} instanceof Object);//true
console.log( [] instanceof Object);//true
console.log( new Date() instanceof Object);//true
console.log( /^d+/ instanceof Object);//true

console.log( new Object() instanceof Function);//false
console.log( function(){} instanceof Function);//true
console.log( new Array() instanceof Function);//false
console.log( new Date() instanceof Function);//false
console.log( new RegExp() instanceof Function);//false


//基本类型
console.log(1 instanceof Number);//false
console.log('1' instanceof String);//false
console.log(true instanceof Boolean);//false
// console.log(null instanceof Null);//false
console.log(null instanceof Object);//false 空引用
console.log(undefined instanceof Object);//false
//Symbol
console.log(Symbol(1) instanceof Symbol);//false
console.log(Symbol(1) instanceof Object);//false
console.log(Symbol(11) instanceof Function);//false

//constructor 返回对象的构造函数
console.log({}.constructor);//[Function: Object]
console.log([].constructor);//[Function: Array]
console.log(function(){}.constructor);//[Function: Function]
console.log(new Date().constructor);//[Function: Date]
console.log(/^d+/.constructor);//[Function: RegExp]
console.log(Symbol(1).constructor);//[Function: Symbol]

//引申 包装类 Number String Boolean
console.log(new Number(1).constructor);//[Function: Number]
console.log(new String("1").constructor);//[Function: String]
console.log(new Boolean(1).constructor);//[Function: Boolean]

//基本类型
console.log((11).constructor); //[Function: Number]
console.log('22'.constructor);//[Function: String]
console.log(true.constructor);//[Function: Boolean]
// console.log(null.constructor);//报错
// console.log(undefined.constructor);//报错
console.log(Symbol(1).constructor);//[Function: Symbol]

//isArray
console.log(Array.isArray([1,2,3]));//true
//Object.prototype.toString.call(obj)
//基本类型
console.log(Object.prototype.toString.call(1));//[object Number]
console.log(Object.prototype.toString.call('11'));//[object String]
console.log(Object.prototype.toString.call(true));//[object Boolean]
console.log(Object.prototype.toString.call(null));//[object Null]
console.log(Object.prototype.toString.call(undefined));//[object Undefined]
console.log(Object.prototype.toString.call(Symbol));//[object Symbol]
//引用对象
console.log(Object.prototype.toString.call({}));//[object Object]
console.log(Object.prototype.toString.call([]));//[object Array]
console.log(Object.prototype.toString.call(function () {  }));//[object Function]
console.log(Object.prototype.toString.call(new Date()));//[object Date]
console.log(Object.prototype.toString.call(Date.now()));//[object Number]
console.log(Object.prototype.toString.call(/^d+/));//[object RegExp]

//包装类
console.log(Object.prototype.toString.call(new Object()));//[object Object]
// 一些类型已经改写了toString的方法  https://blog.csdn.net/hanyanshuo/article/details/104620122

//自定义类和实例






